/**
 * Created by Administrator on 2017/4/12.
 */
/**
 * Created by Administrator on 2017/3/30.
 */
app.controller('detailSpecCtr',
    ['$scope','$location','$http','$rootScope','$routeParams','$sce', function ($scope,$location,$http,$rootScope,$routeParams,$sce) {

        // var columnId=$routeParams.columnId;
        // $http.jsonp( 'http://172.19.32.122:81/app_if/getArticles?columnId='+columnId+'&lastFileId=0&count=30&rowNumber=0&version=0&adv=1&jsoncallback=JSON_CALLBACK'
        // ).success(function(data,header,config,status){
        //     $scope.SpecFocudataList=data;
        //     $scope.SpecFocudataListTab=data.list;
        // }).error(function(data,header,config,status){
        // });

       /* // 详情列表
        alert($rootScope.speciParentColumnId);
        // $scope.speciParentColumnId=$routeParams.linkID;
        $http.jsonp(DetailSpecOneData+'/app_if/getColumns?siteId=1&parentColumnId='+$rootScope.speciParentColumnId+'&version=0&columnType=-1&jsoncallback=JSON_CALLBACK'
        ).success(function(data,header,config,status){
            $scope.specDetaiData=data;
            $scope.specDetaiDataColumns=data.columns;
            console.log("兴趣")
           console.log($scope.specDetaiDataColumns)
            var specDetaiDataColumns= $scope.specDetaiDataColumns;

            // 详情1内容
            $scope.DetailSpecContData=[];
            for(var i=0;i<specDetaiDataColumns.length;i++){

                $http.jsonp( DetailSpecOneData+'/app_if/getArticles?columnId='+specDetaiDataColumns[i].columnId+'&lastFileId=0&count=30&rowNumber=0&version=0&adv=1&jsoncallback=JSON_CALLBACK'
                ).success(function(datas,header,config,status){
                    $scope.DetailSpecContData.push(datas);
                }).error(function(data,header,config,status){
                });

            }
            console.log($scope.DetailSpecContData)

        }).error(function(data,header,config,status){
        });*/
        // 专题详情1列22表

        var coumStr=$routeParams.columnId;
        var linkIdIndex=coumStr.indexOf('linkId');
        var linkId=coumStr.slice(linkIdIndex+6,coumStr.length);

        $http.jsonp(DetailSpecOneData+'siteId=1&parentColumnId='+linkId+'&version=0&columnType=-1&jsoncallback=JSON_CALLBACK'
        ).success(function(data,header,config,status){
            $scope.specDetaiData=data;
            $scope.specDetaiDataColumns=data.columns;
            var specDetaiDataColumns= $scope.specDetaiDataColumns;
            console.log("标题")
            console.log(data)

            // 详情1具体内容
            $scope.DetailSpecContData=[];
           /* for(var i=0;i<specDetaiDataColumns.length;i++){
                $http.jsonp(specDetailOneConten+'columnId='+specDetaiDataColumns[i].columnId+'&lastFileId=0&count=30&rowNumber=0&version=0&adv=1&jsoncallback=JSON_CALLBACK'
                ).success(function(datas,header,config,status){
                    $scope.DetailSpecContData.push(datas);
                }).error(function(data,header,config,status){
                });
            }*/

            //let改为var
            for(var i=0;i<specDetaiDataColumns.length;i++){

                (function(i){
                    $scope.DetailSpecContData[i]=[];
                    $http.jsonp(specDetailOneConten+'columnId='+specDetaiDataColumns[i].columnId+'&lastFileId=0&count=30&rowNumber=0&version=0&adv=1&jsoncallback=JSON_CALLBACK'
                    ).success(function(datas,header,config,status){
                        console.log(datas);
                        $scope.DetailSpecContData[i].push(datas);
                    }).error(function(data,header,config,status){
                    });
                })(i);

            }

            console.log("组中22")
            console.log($scope.DetailSpecContData)

        }).error(function(data,header,config,status){
        });

        //回到顶部
        $(".fiBtn").hide();
        $(window).on("scroll", function(){
            if($(window).scrollTop() >0){
                $(".fiBtn").show();
            }else{
                $(".fiBtn").hide();
            }
        });
        $scope.goBackTop=function () {
            $("body").animate({scrollTop: 0}, 300);
        };

}]);

